package com.easylinkin.linkappapi.device.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easylinkin.linkappapi.device.entity.ElectricyRecords;
import com.easylinkin.linkappapi.device.entity.vo.ElectricyRecordsVo;
import com.easylinkin.linkappapi.device.entity.vo.ElectricyStatisticsVo;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;

/**
 * <p>
 * 用电记录 Mapper 接口
 * </p>
 *
 * @author Xiaoyang
 * @since 2022-08-03
 */
public interface ElectricyRecordsMapper extends BaseMapper<ElectricyRecords> {
  
  /**
   * 查询分页
   *
   * @param page        分页参数对象
   * @param electricyRecords 过滤参数对象
   * @return 查询分页结果
   */
  IPage<ElectricyRecords> selectPage(Page page, @Param("electricyRecords") ElectricyRecordsVo electricyRecords);

  /**
   * 查询单条
   *
   * @param id 主键id
   * @return 查询结果
   */
  ElectricyRecords getOneById(@Param("id") Serializable id);

  /**
   * 查询用电记录
   *
   * @param deviceCode 设备号
   * @return
   */
  List<ElectricyRecords> findByDeviceCode(ElectricyRecordsVo electricyRecords);

  /**
   * 按时间用电量统计
   *
   * @param electricyRecords
   * @return
   */
  Double getSumElectricyByTime(ElectricyRecordsVo electricyRecords);

  /**
   * 查询最新一条记录
   * @param electricyRecordsVo
   * @return
   */
  ElectricyRecords getLatestRecord(ElectricyRecordsVo electricyRecordsVo);

  /**
   * 查询最早的一条记录
   * @param electricyRecordsVo
   * @return
   */
  ElectricyRecords getEarlyRecord(ElectricyRecordsVo electricyRecordsVo);

  /**
   * 按时间查询用电量统计趋势图
   * @param electricyRecordsVo
   * @return
   */
  List<ElectricyStatisticsVo> getElectricyStatisticsVoByDay(ElectricyRecordsVo electricyRecordsVo);

  /**
   * 按月份统计一级区域用水量
   * @param tenantId
   * @param time
   * @return
   */
  List<ElectricyRecordsVo> findOneArea(@Param("tenantId") String tenantId, @Param("time") Date time);

  /**
   * list查询
    * @param electricyRecords
   * @return
   */
  List<ElectricyRecords> selectByList(@Param("electricyRecords") ElectricyRecordsVo electricyRecords);

  /**
   *  list查询(全年按天聚合)
   * @param electricyRecords
   * @return
   */
  List<ElectricyRecords>  selectListByYears(@Param("electricyRecords") ElectricyRecordsVo electricyRecords);

  List<ElectricyRecords> codeByNewRecords(@Param("tenantId") String tenantId, @Param("codes") List<String> codes);
}
